﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Problema1;

namespace Problema1
{
    class Program
    {
        static void printData()
        {
            if (mySingletone.vars.Clienti == null)
            {
                Console.Write("Nimic de afisat !!!\r\n");
                return;
            }
            Console.Write("\r\n\r\n");
            for (int i = 0; i < mySingletone.vars.Clienti.getSize(); i++)
            {
                persoana p = mySingletone.vars.Clienti.getPersoana();
                p.printData();
                Console.Write("********************\r\n\r\n");                
            }

        }
        static void Main(string[] args)
        {
            PoolPersoane clienti = mySingletone.vars.Clienti;
            int c;
            while (true)
            {
                Console.Write("Meniu aplicatie :\r\n 1.Adaugati un client\r\n 2.Adaugati o masina\r\n 3.Afisati datele\r\n 4.Iesire\r\n");
                c = 0;
                while (c < 1 || c > 4)
                {
                    try
                    {
                        c = Convert.ToInt32(Console.ReadLine());
                    }
                    catch { }
                    switch (c)
                    {
                        case 1: clienti.addPersoana(new persoana()); break;
                        case 2:
                            string nume;
                            Console.Write("Nume client : ");nume=Console.ReadLine();
                            persoana p = clienti.getPersoana(nume);
                            if (p == null)
                            {
                                Console.Write("Numele nu a fost gasit !\r\n");
                            }
                            else
                                p.adaogaMasina(CumparaMasina.getFactory().CreeazaMasina());
                            break;
                        case 3: printData(); break;
                        case 4: return;
                    };
                }

            }
        }
    }
}
